import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-04-12
 * Time: 16:05
 */
public class Test {
    public boolean IsPopOrder(int [] pushA,int [] popA) {
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for (int i = 0; i < pushA.length; i++) {
            stack.push(pushA[i]);
            while(!stack.empty() && j < popA.length && stack.peek() == popA[j]) {
                stack.pop();
                j++;
            }
        }
        return stack.empty();
    }
    public boolean isValid(String s) {
        Stack<Character> stack = new Stack<>();
        for(int i = 0; i < s.length(); i++) {
            char str = s.charAt(i);
            if(str == '(' || str == '{' || str == '[') {
                stack.push(str);
            } else {
                if(stack.empty()) {
                    return false;
                } else {
                    char str2 = stack.peek();
                    if(str2 == '(' && str == ')' || str2 == '{' && str == '}' || str2 == '[' && str == ']') {
                        stack.pop();
                    } else {
                        return false;
                    }
                }
            }
        }
        if(!stack.empty()) {
            return false;
        }
        return true;
    }
    public int evalRPN(String[] tokens) {
        Stack<Integer> stack = new Stack<>();
        for(String s : tokens) {
            if(!isOpera(s)) {
                stack.push(Integer.parseInt(s));
            } else {
                int num2 = stack.pop();
                int num1 = stack.pop();
                switch(s) {
                    case "+" :
                        stack.push(num1 + num2);
                        break;
                    case "-" :
                        stack.push(num1 - num2);
                        break;
                    case "*" :
                        stack.push(num1 * num2);
                        break;
                    case "/" :
                        stack.push(num1 / num2);
                        break;
                }
            }
        }
        return stack.pop();
    }
    public boolean isOpera(String x) {
        if(x.equals("+") || x.equals("-") || x.equals("*") || x.equals("/")){
            return true;
        }
        return false;
    }
    public static void main(String[] args){
        MyStack myStack = new MyStack();
        myStack.push(1);
//        myStack.push(2);
//        myStack.push(3);
//        myStack.push(4);
        System.out.println("==========");
        System.out.println(myStack.pop());
        //myStack.pop();
    }
    public static void main1(String[] args) {
        Stack<Integer> stack = new Stack<>();
        //底层是一个数组
        stack.push(12);
        stack.push(23);
        stack.push(34);
        //删除栈顶元素
        int x = stack.pop();
        System.out.println(x);

        //获取当前栈顶元素
        int y = stack.peek();
        System.out.println(y);
        //判断是否为空
        System.out.println(stack.empty());
    }
}
